package cn.webrx;/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */

import java.time.LocalDate;

/**
 * <p>Project: javase - cn.webrx.Switch3
 * <p>Powered by webrx On 2021-11-25 09:24:58
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Switch6 {
    public static void main(String[] args) {
        int y = 2021;
        int m = 11;
        //java 12 表达式
        int day = switch (m) {
            case 4, 6, 9, 11 -> 30;
            case 2 -> LocalDate.of(y, m, 1).isLeapYear() ? 29 : 28;
            default -> 31;
        };
        System.out.printf("%d年%d月有%d天。%n", y, m, day);
    }
}
